package com.decent.ejfadmin.user.controller;

import com.decent.ejfadmin.common.bean.MessageBean;
import com.decent.ejfadmin.user.bean.AdminRole;
import com.decent.ejfadmin.user.bean.ShiroButton;
import com.decent.ejfadmin.user.service.AdminButtonShiroService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * describe:按钮权限
 *
 * @author 陈豆豆
 * @date 2019/10/07
 */
@RestController
@RequestMapping("adminButton")
@Slf4j
public class AdminButtonShiroController {
    @Autowired
    private AdminButtonShiroService adminButtonShiroService;

    /**
     * 获取当前用户按钮权限
     *
     * @return
     */
    @RequestMapping("getBtnShiro")
    public MessageBean getBtnShiro() {
        return adminButtonShiroService.getBtnShiro();
    }

    /**
     * 获取当前用户按钮权限
     *
     * @return
     */
    @RequestMapping("rebindButton")
    public MessageBean rebindButton(Integer[] roleId, Integer[] buttonId) {
        return adminButtonShiroService.rebindButton(roleId, buttonId);
    }


    /**
     * 获取当前用户转账申请审核按钮权限
     *
     * @return MessageBean
     */
    @RequestMapping("getTransferApplyBtnShiro")
    public MessageBean getTransferApplyBtnShiro() {
        return adminButtonShiroService.getTransferApplyBtnShiro();
    }

    /**
     * 获取按钮列表
     *
     * @return
     */
    @RequestMapping("getAllButton")
    public List<ShiroButton> getAllButton() {
        return adminButtonShiroService.getAllButton();
    }

    /**
     * 获取所有角色
     *
     * @return
     */
    @RequestMapping("getAllRole")
    public List<AdminRole> getAllRole() {
        return adminButtonShiroService.getAllRole();
    }

    /**
     * 查询已绑定的角色
     *
     * @param bindRoleIds
     * @return
     */
    @RequestMapping("queryBoundRole")
    public List<AdminRole> queryBoundRole(String bindRoleIds) {
        if (StringUtils.isBlank(bindRoleIds)) {
            return null;
        }
        return adminButtonShiroService.queryBoundRole(bindRoleIds);
    }
}
